#define DUBUG
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;

const int maxn=250, c=1000, maxt=1000, maxlim=1000;

int min(int a, int b) {
	return a<b ? a : b;
}

ll max(ll a, ll b) {
  return a>b ? a : b;
}

bool check(int n, int x, ll w[], ll t[], int lim) {
  ll sum=0;
  for (int i=1; i<=n; i++) {
    if (t[i]*c>=w[i]*x) {
      lim -= w[i];
      sum += t[i]*c-w[i]*x;
    }
  }
  static ll f[maxlim+1];
  memset(f, 128, sizeof f);
  f[0] = 0;
  for (int i=1; i<=n; i++) {
    if (t[i]*c<w[i]*x) {
      for (int j=lim; j>=0; j--) {
				f[min(j+w[i], lim)] = max(f[min(j+w[i], lim)], f[j]+t[i]*c-w[i]*x);
      }
    }
  }
  return f[lim]+sum>=0;
}

int main() {
  freopen("show.in", "r", stdin);
  freopen("show.out", "w", stdout);

  static ll w[maxn+1], t[maxn+1];
  int n, lim;
  scanf("%d %d", &n, &lim);
  for (int i=1; i<=n; i++) {
    scanf("%lld %lld", w+i, t+i);
  }

  int ans=0;
  for (int x=1, y=maxt*c, mid; x<=y; ) {
    mid = (x+y)/2;
    if (check(n, mid, w, t, lim)) {
      ans = mid;
      x = mid+1;
    } else {
      y = mid-1;
    }
  }
  printf("%d", ans);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
